package com.ruoyi.project.search.viewStockDetail.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.project.search.viewStockDetail.domain.ViewStockDetail;
import com.ruoyi.project.search.viewStockDetail.mapper.ViewStockDetailMapper;
import com.ruoyi.project.search.viewStockDetail.service.IViewStockDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.text.Convert;

/**
 * 库存明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-06-02
 */
@Service
public class ViewStockDetailServiceImpl implements IViewStockDetailService
{
    @Autowired
    private ViewStockDetailMapper viewStockDetailMapper;

    /**
     * 查询库存明细
     * 
     * @param stockId 库存明细主键
     * @return 库存明细
     */
    @Override
    public ViewStockDetail selectViewStockDetailByStockId(String stockId)
    {
        return viewStockDetailMapper.selectViewStockDetailByStockId(stockId);
    }

    /**
     * 查询库存明细列表
     * 
     * @param viewStockDetail 库存明细
     * @return 库存明细
     */
    @Override
    public List<ViewStockDetail> selectViewStockDetailList(ViewStockDetail viewStockDetail)
    {
        return viewStockDetailMapper.selectViewStockDetailList(viewStockDetail);
    }

    /**
     * 新增库存明细
     * 
     * @param viewStockDetail 库存明细
     * @return 结果
     */
    @Override
    public int insertViewStockDetail(ViewStockDetail viewStockDetail)
    {
        return viewStockDetailMapper.insertViewStockDetail(viewStockDetail);
    }

    /**
     * 修改库存明细
     * 
     * @param viewStockDetail 库存明细
     * @return 结果
     */
    @Override
    public int updateViewStockDetail(ViewStockDetail viewStockDetail)
    {
        return viewStockDetailMapper.updateViewStockDetail(viewStockDetail);
    }

    /**
     * 批量删除库存明细
     * 
     * @param stockIds 需要删除的库存明细主键
     * @return 结果
     */
    @Override
    public int deleteViewStockDetailByStockIds(String stockIds)
    {
        return viewStockDetailMapper.deleteViewStockDetailByStockIds(Convert.toStrArray(stockIds));
    }

    /**
     * 删除库存明细信息
     * 
     * @param stockId 库存明细主键
     * @return 结果
     */
    @Override
    public int deleteViewStockDetailByStockId(String stockId)
    {
        return viewStockDetailMapper.deleteViewStockDetailByStockId(stockId);
    }

    /**
     * 指定货位出库调用存储过程
     * @param stockId  库存编号
     * @return
     */
    @Override
    public int assignOut(String stockId) {
        Map<String, Object> params = new HashMap<>();
        params.put("stockId", stockId);
        params.put("type", 1);
        viewStockDetailMapper.assignOut(params);
        return (int) params.get("resultCode");
    }
}
